I have string:
<p>Lorem ipsum dolor sit amet. <object width="500" height="500" type="application/x-shockwave-flash"
data="http://www.abc.com/m/l5J16d65wOpT" style="display: block; margin-left: auto; margin-right: auto;">
<param value="always" name="allowscriptaccess">
</object> Lorem ipsum dolor sit amet</p> Lorem ipsum dolor sit amet
Now, i want to add <div class="player"></div> around object tag, it's will become:
<p>Lorem ipsum dolor sit amet. <div class="player"><object width="500" height="500" type="application/x-shockwave-flash"
data="http://www.abc.com/m/l5J16d65wOpT" style="display: block; margin-left: auto; margin-right: auto;">
<param value="always" name="allowscriptaccess">
</object></div> Lorem ipsum dolor sit amet</p> Lorem ipsum dolor sit amet
a preg_replace might be useful here :)
$result = preg_replace('|(<object.*</object>)|sui', '<div class="player">$1</div>', $html);
If you want to replace it like this, then just use the normal str_replace
//PHP
$myString = str_replace("<object>", "<div class=\"player\"><object>", $originalString);
$myString = str_replace("</object>", "</object></div>", $originalString);
Related
I am trying to get all of the slides in my orbit slider to be the height of the largest slide.
Here is my markup:
$(document).ready(function(){
$('.orbit-container').equalize('outerHeight');
});
<div class="orbit" data-orbit="" role="region" data-auto-play="false" data-resize="7sdsk0-orbit" id="7sdsk0-orbit" data-t="3k1v70-t"><button class="orbit-previous" tabindex="0"><span class="show-for-sr">Previous Slide</span>◀︎</button><button class="orbit-next" tabindex="0"><span class="show-for-sr">Next Slide</span>▶︎</button><div class="orbit-wrapper">
<ul class="orbit-container" data-options="bullets: true; autoPlay:false;" data-auto-play="false" data-equalizer="" data-equalize-on-stack="true" data-equalize-by-row="true" data-resize="lo2q16-eq" data-mutate="k2tsn5-eq" data-t="fgxh6n-t" tabindex="0" style="height: 0px;" data-events="mutate">
<li data-equalizer-watch class="orbit-slide" data-slide="0">
<div>
<div class="text-container">
<h1>Arthritis. Give Before it takes.</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisi elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, nostrud</p>
Learn More
</div>
<div class="inner-overlay"> </div>
<img alt="" class="orbit-image desktop" src="/AS/media/AS/Homepage%20Billboards/billboard-tweaked.jpg?ext=.jpg">
<img alt="" class="orbit-image mobile" src="/AS/media/AS/Homepage%20Billboards/mobile-cropped.jpg?ext=.jpg">
</div>
</li>
<li data-equalizer-watch class="orbit-slide is-active" data-slide="1" aria-live="polite">
<div>
<div class="text-container">
<h1>Lorem ipsum dolor sit amet</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisi elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, nostrud</p>
Learn More
</div>
<div class="inner-overlay"> </div>
<img alt="" class="orbit-image desktop" src="/AS/media/AS/Homepage%20Billboards/billboard-tweaked.jpg?ext=.jpg">
<img alt="" class="orbit-image mobile" src="/AS/media/AS/Test%20Images/rough-mobile.jpg?ext=.jpg">
</div>
</li>
</ul>
</div>
On each li, an inline style is being applied of height="auto", so the slides are different heights. Even if I call that function after the window has loaded, it has the same effect.
Am I missing something?
THE SITUATION:
I need to use the text-wrap for an ion-card but it seems it doesn't work.
THE CODE:
<ion-card>
<ion-card-header text-wrap>
<h2> <ion-icon name="list-box"></ion-icon> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labor</h2>
</ion-card-header>
<ion-card-content>
<p>content</p>
</ion-card-content>
</ion-card>
THE PLUNKER:
http://plnkr.co/edit/z5ehOQgz0oArhg6mMtUj?p=preview
THE QUESTION:
There is a way to use text-wrap for the ion-card?
<ion-card-header text-wrap>
you can use text-wrap in other components too.
Ok, setting white-space: normal; to the ion-card-header fixed this.
<ion-card-header style="white-space: normal;"> could be placed in css file as well.
Plunker: http://plnkr.co/edit/GjDmJBNMdnoPiteAKpDB
white-space: normal; is correct. But it should be placed on the header tag IE h2. By default "ion-labels" (a class that can be injected into the DOM) have white-space: nowrap; applied to them. So setting white-space: normal; on the header tag selecting the ion-label tag through css will work.
I try to understand how Ember works and I have an issue I can't understand. I am following a tutorial (guides.emberjs.com/v1.10.0/) and I don't understand why I only see an element when I go on a page when I click (and doesn't work with a direct link).
I think some screenshots will be helpful to understand my issue.
This is what I have when I visit "index.html#/posts/1". No article is displayed.
http://i.stack.imgur.com/qzwlq.png
This is what I have when I visit "index.html#/posts" and then click on Rails is Omakase on the left. An article is displayed whereas the link is on my browser is "index.html#/posts/1" (and when I refresh nothing is displayed).
http://i.stack.imgur.com/YpmzX.png
This is my index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Blog tuto</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css">
</head>
<body>
<script type="text/x-handlebars">
<div class="navbar">
<div class="navbar-inner">
<a class="brand" href="#">Bloggr</a>
<ul class="nav">
<li>{{#link-to "posts.index"}}Posts{{/link-to}}</li>
<li>{{#link-to "about"}}About{{/link-to}}</li>
</ul>
</div>
</div>
{{outlet}}
</script>
<script type="text/x-handlebars" id="about">
<p>
Lorem ipsum about
</p>
</script>
<script type="text/x-handlebars" id="posts">
<div class="container-fluid">
<div class="row-fluid">
<div class="span4">
<table class="table">
<thead>
<tr><th>Recent Posts</th></tr>
</thead>
{{#each post in model}}
<tr>
{{#link-to "posts.post" post}}
<td>{{post.title}} <small class="muted">by {{post.author}}</small></td>
{{/link-to}}
</tr>
{{/each}}
</table>
</div>
<div class="span8">
{{outlet}}
</div>
</div>
</div>
</script>
<script type="text/x-handlebars" id="posts/post">
{{#if isEditing}}
{{partial "post/edit"}}
<button {{action "doneEditing"}}>Done</button>
{{else}}
<button {{action "edit"}}>Edit</button>
{{/if}}
<h1>{{title}}</h1>
<h2><small class="muted">by {{author}}</small></h2>
<hr>
<div class="intro">
{{exerpt}}
</div>
<div class="below-the-fold">
{{body}}
</div>
</script>
<script type="text/x-handlebars" id="post/edit">
<p>{{input type="text" value=title}}</p>
<p>{{input type="text" value=exerpt}}</p>
<p>{{textarea value=body}}</p>
</script>
<script src="../js/libs/jquery.min.js"></script>
<script src="../js/libs/handlebars.js"></script>
<script src="../js/libs/ember.js"></script>
<script src="../js/libs/ember-data.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.1.0/moment.min.js"></script>
<script src="app.js"></script>
</body>
</html>
And app.js
App = Ember.Application.create();
App.Router.map(function() {
this.route('about');
this.resource('posts', function () {
this.route('post', {path: ':post_id'});
});
});
App.PostsRoute = Ember.Route.extend({
model: function () {
return posts;
}
});
App.PostsPostRoute = Ember.Route.extend({
model: function (params) {
return posts.findBy('id', params.post_id);
}
});
App.PostsPostController = Ember.ObjectController.extend({
isEditing: false,
actions: {
edit: function () {
this.set('isEditing', true);
},
doneEditing: function () {
this.set('isEditing', false);
}
}
});
var posts = [{
id: 1,
title: "Rails is Omakase",
author: "mc100s",
date: new Date('08-06-2015'),
exerpt: "Lorem ipsum dolor sit amet",
body: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
}, {
id: 2,
title: "The Parley Letter",
author: "mc100s",
date: new Date('08-06-2015'),
exerpt: "Duis aute irure dolor in reprehenderit",
body: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
}];
Thank you for your help
When you click link, model is passed directly to the route and route's model hook is not fired, so you see article. When you reload route model hook is fired and something goes wrong.
Make string id, because params.post_id is String.
findBy is Ember.Array method. http://emberjs.com/api/classes/Ember.Array.html#method_findBy
I would try:
var posts = Ember.A([{
// as is
}]);
Next change ObjectController to Controller (ObjectController is deprecated) and use {{model.title}} instead of {{title}} in template:
<script type="text/x-handlebars" id="posts/post">
{{#if isEditing}}
{{partial "post/edit"}}
<button {{action "doneEditing"}}>Done</button>
{{else}}
<button {{action "edit"}}>Edit</button>
{{/if}}
<h1>{{model.title}}</h1>
<h2><small class="muted">by {{model.author}}</small></h2>
<hr>
<div class="intro">
{{model.exerpt}}
</div>
<div class="below-the-fold">
{{model.body}}
</div>
working jsbin here: http://jsbin.com/pozabixeka/edit?html,js,output
I want to get a string like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tempor pulvinar enim! Nec aliquam massa faucibus sed?? Praesent nec consectetur sapien... Nulla dapibus rutrum turpis, ac porta erat posuere vel.
starting from string in all uppercase (or lowercase). For example:
LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT. DONEC TEMPOR PULVINAR ENIM! NEC ALIQUAM MASSA FAUCIBUS SED?? PRAESENT NEC CONSECTETUR SAPIEN... NULLA DAPIBUS RUTRUM TURPIS, AC PORTA ERAT POSUERE VEL.
How can I do?
Thank you!
Take your text and set it to a variable like this:
<cfset stringFixer = "LOREM IPSUM DOLOR SIT AMET, CONSECTETUR ADIPISCING ELIT. DONEC TEMPOR PULVINAR ENIM! NEC ALIQUAM MASSA FAUCIBUS SED?? PRAESENT NEC CONSECTETUR SAPIEN... NULLA DAPIBUS RUTRUM TURPIS, AC PORTA ERAT POSUERE VEL.">
Lowercase everything:
<cfset stringFixer = lCase(stringFixer)>
Then you will need to match your string terminator with rematch like this:
<cfset stringFixerBreaker = reMatch('\w.+?[.?]+',stringFixer)>
reMatch() will break apart your string into smaller discrete sentence strings...Then you could do a replaceNoCase() with left search for the first char then do the same with your replacement string which will be the same but we will throw a uCase() on that first character to capitalize it.
<cfloop array="#stringFixerBreaker#" index="i">
<cfoutput>#replaceNoCase(i,left(i, 1 ),uCase(left(i, 1 )))# </cfoutput>
</cfloop>
Your output will look like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tempor pulvinar enim! nec aliquam massa faucibus sed?? Praesent nec consectetur sapien... Nulla dapibus rutrum turpis, ac porta erat posuere vel.
Edit: One last touch point to my answer.
If you need to rebuild the string do this:
<cfset str = "">
<cfloop array="#stringFixerBreaker#" index="i">
<cfset str = str & replaceNoCase(i,left(i, 1 ),uCase(left(i, 1 ))) & " ">
</cfloop>
Dump out the results to check everything is in order:
<cfdump var="#str#">
I would use CSS rather than ColdFusion to do this
<span style="text-transform : capitalize"><cfoutput>#lcase(mystring)#</cfoutput></span>
While I personally like #James A Mohler solution, you can also do this in CF using a simple regex.
function Initcap(text){
return rereplace(lcase(arguments.text), "(\b\w)", "\u\1", "all");
}
The best way is by using regex and ReReplace or ReReplaceNoCase.
<cfset mystring = "lorem ipsum"/>
#ReReplace(mystring ,"\b(\w)","\u\1","ALL")#
Here is my approach and it works in all cases except in a situation such as mc'donald's. I can get it to capitalize the "d" but then the "s" would also be capitalized. Mc'Donald'S.
<cfif ISDefined('mywds')>
<cfoutput>
#mywds#<br>
<cfset catz = #LCase(mywds)#>
<cfloop index="dogz" list="#catz#" delimiters=" ">
<cfif Len(dogz) is 1 >
#UCase(dogz)#
<cfelse>
#Left(UCase(dogz), 1 )##Right(LCase(dogz),
Len(dogz) - 1 )#
</cfif>
</cfloop>
</cfoutput>
</cfif>
<cfform action="" method="POST" target="_self">
<input type="text" name="mywds" size="50"><br>
<input type="submit" name="submit" value="Submit">
</cfform>
This is a working form so you can paste in a .cfm page and it will function.
The 2nd cfif statement:
<cfif Len(dogz) is 1 >
is so if someone enters text like "john t williams" the code will not throw an error on the single character "t".
The title might not be clear, but I don't know how else to put it..
In the Django documentation it's pretty clear how to mark a text block for translation .. Take this example:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec quam sem, sodales in fringilla nec, lacinia a lorem.
Vivamus vel molestie ante.
So far so good. You just either use the trans or blocktrans tag.
But now consider this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec quam sem, sodales in fringilla nec, lacinia a lorem.
Vivamus vel molestie ante.
How should I deal with this ? Do I just wrap it in a block trans ?
Edit:
I think I've found out how it should be done ..
{% url some-view as some_view_url %}
{% blocktrans %}
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec quam sem, sodales in fringilla nec, lacinia a lorem.
Vivamus vel molestie ante.
{% endblocktrans %}
I would definitely use blocktrans. Sometimes its not possible to split i18n html text into different fragments. Blocktrans has some powerfull features:
{% url path.to.view arg arg2 as the_url %}
{% blocktrans with object.title as title and author|title as author_t %}
{{author}}: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec quam sem, sodales in fringilla nec, lacinia a lorem.
{{title}} molestie ante.
{% endblocktrans %}
Have a look at:
url template tag
blocktrans template-tag