If you have problems or question or simply have a request, please contact me.
Add the file to your page using :
<!-- basic stylesheet -->
<link rel="stylesheet" href="newsWidget/css/newsWidget.css">
<!-- OPTIONAL! ADD a theme for easy customization-->
<link rel="stylesheet" href="newsWidget/css/newsWidget_theme.css">
<!-- Plugin requires jQuery 1.7+ and TweenMax -->
<!-- If you already have jQuery on your page, you shouldnt include it second time. -->
<script src='newsWidget/js/jquery-1.8.3.min.js'></script>
<!-- If you already have TweenMax on your page, you shouldnt include it second time. -->
<script src="newsWidget/js/TweenMax.min.js"></script>
<!-- News Widget JS script file -->
<script src="newsWidget/js/query.newsWidget.pack.min.js"></script>
<!-- basic stylesheet -->
<link rel="stylesheet" href="newsWidget/css/newsWidget.css">
<!-- OPTIONAL! ADD a theme for easy customization-->
<link rel="stylesheet" href="newsWidget/css/newsWidget_theme.css">
<!-- Plugin requires jQuery 1.7+ and TweenMax -->
<!-- If you already have jQuery on your page, you shouldn't include it second time. -->
<script src='newsWidget/js/jquery-1.8.3.min.js'></script>
<!-- If you already have TweenMax on your page, you shouldn't include it second time. -->
<script src="newsWidget/js/TweenMax.min.js"></script>
<!-- News Widget JS script file -->
<script src="js/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="js/jquery.jfeed.pack.js"></script>
<script src="js/jquery.newsWidget.min.js"></script>
<!-- I've included a non minified version in the folder. -->
If you plan or need to edit the plugin in any way, you're going to want to use the 'split' version. But if you don't plan on making any edits, you can use the 'minified' version instead.
Each list tag <li></li> will be treated as an indipendent news. You can use html code in the body of the news. Meaning you can add all posible tags including buttons, forms, images, lists or any possible thing!
<ul id="mainNewsWidget">
<!-- Minimal Settings -->
<li data-title="title" data-date="24-6-2013" >
Body of article.Text or html code.
</li>
..
<!-- Example 1 -->
<li data-title="HTC Released HTC ONE." data-date="24-6-2013" >
<h2> A heading 2 </h2>
<p> A paragraph here <img src="img.jpg" /> </p>
Features
<ul>
<li> 4.7 Inch </li>
<li> Sense 5 </li>
</ul>
</li>
</ul>
For plugin settings, check options section.
<script>
jQuery(document).ready(function($) {
$("#divID").newsWidget({
// Options go here
// Example, choose the full article mode.
fullArticleType : "full"
});
});
</script>
Variable | Default Value | Description | |||||||
---|---|---|---|---|---|---|---|---|---|
currentNewsWidth | 800 | Width of the Current News Widget. | |||||||
currentNewsHeight | 280 | Height of the Current News Widget. | |||||||
currentAlign (V1.1) | "center" | Accepts 2 values: "center" and "top". Alignment of white box. | |||||||
numberOfNews | 2 | If set, the height of the widget will be recalculated. To set it, use a +ve number. Use a -ve one to deactivate | |||||||
widgetHeight | 540 | Applicable if numberOfNews was set to a -ve value. Height of the whole news Widget. The plugin will automatically calculate how many news items to fit and disregard extra space. Actual height will eb calculated based on those numbers. | |||||||
fullArticleType | widget | How the news article will expand when pressed. Available options: "full" or "widget" | |||||||
navBtns | sides | Sets the arrows position Available options: "left" "right" "sides" "top-left" "top-right" "bottom-left" "bottom-right" "top/bottom". | |||||||
closedNewsWidth | 500 | in px, the width of the closed news item. | |||||||
closedNewsPosition | left | Aligns the news items to the widget. Options: "left" or "right" | |||||||
closedNewsOffset | 50 | in px, apply offset with respect to position | |||||||
maxLetters | 330 | letters to display in description | |||||||
widgetOpenType | fadeDown | How the widget(whole news reader) will initially appear. Options: "none", "fade", "slideRight", "slideLeft", "slideUp", "slideDown", "fadeUp", "fadeDown", "fadeLeft", "fadeRight" | |||||||
imgCrop | true | if true, the image will be cropped if required. | |||||||
imgHeight | 150 | image height if crop is enabled. | |||||||
imgInPreview (V1.1) | false | if true, the image will be display in widget. (if false image will still appear on expanding to fullpage/inline previewer. | |||||||
widgetOpenDelay | 0.5 | in seconds, the delay of the widget open. | |||||||
widgetOpenDuration | 0.5 | in seconds, the duration of the widget open. | |||||||
fullArticleOpen | fadeLeft | How the news opens (full-page and widget). Options: "none", "fade", "slideRight", "slideLeft", "slideUp", "slideDown", "fadeUp", "fadeDown", "fadeLeft", "fadeRight" | |||||||
fullArticleClose | fadeRight | How the news closes (full-page and widget). Options: "none", "fade", "slideRight", "slideLeft", "slideUp", "slideDown", "fadeUp", "fadeDown", "fadeLeft", "fadeRight" | |||||||
fullArticleOpenDelay | 0.1 | in seconds, the delay of the full article animation. | |||||||
fullArticleAnimationDuration | 0.5 | in seconds, the delay of the full article animation. | |||||||
animationsDuration | 0.4 | in seconds, all animatiosn Durations. Except ones defined above | |||||||
easeing | Expo.easeOut | Easings. http://www.greensock.com/get-started-js/#easing contain all supported easing | |||||||
currentNewsHoverType | 1 | Current News Hover type. Options:1 or 2 | |||||||
linkText | Read | The text that will appear when you hover over the current news. | |||||||
titleInLink | after | Include title in the text. Options: "before" or "after" or "none" | |||||||
linkTarget | blank | Target of links. Options: "blank", "self", "parent" | |||||||
readMoreTxt | Continue Reading .. | text that will appear after each article if you choose readmore type links or in rss feeds. | |||||||
feed | none | none or url | |||||||
feedReadMoreType | insite | Options: insite, external. insite will add a "Continue Reading..." button to the article while external will link directly. | |||||||
feedMaxNum | 10 | Maximum number of feeds to load. |
<!-- This is OPTIONAL-->
<!-- You can override default settings(options used in initializer) by adding attributes to specific News Items.-->
<!-- Those options will be only added to that item.-->
<ul id="mainNewsWidget">
<!-- Example overriding all settings.-->
<!-- Each one will be explained below with an example..-->
<li data-title="title"
data-date="24-6-2013"
data-image="img.jpg"
data-image-cropping="true"
data-image-height="230"
data-link="http://google.com"
data-link-type="readmore"
data-link-text="View "
data-title-in-link="after">
Body of article.Text or html code.
</li>
</ul>
All of these are attributes are optional:
<ul id="newsWidget">
<!--Add an Image like this.-->
<li data-title="title"
data-date="24-6-2013"
data-image="img.jpg"
</li>
</ul>
Variable | Default Value | Description | |||||||
---|---|---|---|---|---|---|---|---|---|
imgCrop | true | if true, the image will be cropped if required. | |||||||
imgHeight | after | Image height if crop is enabled. |
Example of initializing newsWidget with Image options:
<!-- Initialization settings
-->
jQuery(document).ready(function($) {
$("#newsWidget").newsWidget({
imgCrop: true, //if true, the image will be cropped if required.
imgHeight: 200, //img height if crop is enabled
// other options can be used
});
});
<ul id="newsWidget">
<!-- This will give an image a custom height-->
<li data-title="This has a custom Height"
data-date="24-6-2013"
data-image="img.jpg"
data-image-height="330"
</li>
<!-- This will override the default cropping settings.-->
<li data-title="This doesnt crop image"
data-date="24-6-2013"
data-image="img.jpg"
data-image-cropping="false"
</li>
</ul>
<ul id="newsWidget">
<li data-title="This will open directly"
data-date="24-6-2013"
data-link="http://google.com"
</li>
<li data-title="This will add a readMore button after each news."
data-date="24-6-2013"
data-link="http://google.com"
data-link-type="readmore"
</li>
</ul>
Variable | Default Value | Description | |||||||
---|---|---|---|---|---|---|---|---|---|
linkTarget | blank | Target of links. Options: "blank", "self", "parent" | |||||||
readMoreTxt | Continue Reading .. | text that will appear after each article if you choose readmore type links or in rss feeds. |
Example of initializing newsWidget with link options:
<!-- Initialization settings
-->
jQuery(document).ready(function($) {
$("#feedWidget").newsWidget({
linkTarget: blank, //if true, the image will be cropped if required.
readMoreTxt: "Read More...", //img height if crop is enabled
// other options can be used
});
});
<ul id="newsWidget">
<li data-title="This will have the default one"
data-date="24-6-2013"
</li>
<li data-title="This will have a custom link text saying: View 'The title of this article'."
data-date="24-6-2013"
data-link-text="View "
data-title-in-link="after"
</li>
</ul>
Variable | Default Value | Description | |||||||
---|---|---|---|---|---|---|---|---|---|
linkText | Read | The text that will appear when you hover over the current news. | |||||||
titleInLink | after | Include title in the text. Options: "before" or "after" or "none" |
Example of initializing newsWidget with link options:
<!-- Initialization settings
-->
jQuery(document).ready(function($) {
$("#newsWidget").newsWidget({
linkText:"Read: " , //text that will appear when you hover over the current news.
titleInLink : "after", //include title in the text. Options: "before" or "after" or "none"
// other options can be used
});
});
<!-- Add this to where you want to display the widget-->
<ul id="feedWidget"> </ul>
<!-- Initialization settings
-->
<script>
jQuery(document).ready(function($) {
$("#feedWidget").newsWidget({
// only the feed is required
feed : "urltofeed.rss",
// Additional feed-only Options
feedReadMoreType: "insite",
feedMaxNum: 10
// other options can be used
});
});
</script>
I've included a skeleon css newsWidget_theme.css that will make it easier for begginers to edit the properties. This file includes properties i thought are enough to change the look of the plugin. More advanced users can go ahead and edit the newsWidget.css directly (but remember to not include the theme css).
Because some users wont edit the css, the width and height of the widget is defined in js and not css. All other stylings(color, font,size of closed news, btn...) can be customized via the css file.
The scroller used is a plugin. I've embeded it's css in the plugin's css starting line 310 till the end. Don't worry, I've included the major properties in the skeleton css files!
To add one of the included themes:
<!-- Change this to your desired theme.-->
<link rel="stylesheet" href="newsWidget/css/newsWidget_theme.css">
<!-- Example-->
<link rel="stylesheet" href="newsWidget/css/newsWidget_mini.css">
Make sure to copy that file to your server!
The News Widget will inherit the font used in the page.
Open the css theme file and Remove one line (at the top, instruction found there)!
For example, for google fonts u only need to add 1 line to the html page, and edit the font family in the css theme file (instruction found in top of css file).