Friday 24 April 2015

Link-List Navigation for Shopify (Nested Navigation).

Main Menu is header menu list on Front of Page and for adding a category drop down menu. Click on Adding Link list and give the name and add link in this panel. 
 
Note: The Category name(Sub navigation name) is also add in Main Menu as a collection.
 
Adding Link List

 *Name = Category 

 *Add Link = Commercial, Residential

Main Menu

Edit Link list

Friday 17 April 2015

Cross-Domain Communication by iFrame Usinig javascript (onHashchangeEvent)

In iframe if we are on same domain then it's not to difficult to sending data between application and iFrame but what we do when both are different domain so there is something trick or a concept to sending data between different domain.

i Using javascript onhashchange event and first some code that will encode arbitrary data (as long as it’s JSON encodable) and put it into the hash value of the desired iframe.

function sendIFrameData( frame, data ){
    var idx = frame.src.indexOf('#'), url = frame.src;
    if ( idx > -1 ){
        url = url.substr(0, idx);
    }
   
    frame.src = url + '#' + window.btoa(JSON.stringify(data));
}

Now on the iframe side, let’s write a function to decode the data.

function getHashData(){
    var data;
    try {
        data = JSON.parse(window.atob(window.location.hash.substr(1)));
    } catch( e ){}
    return data;
}



In my application i add this code this is working for me ... !
iframe on my domain, and send it some messages.

// send arbitrary data to the iframe


sendIFrameData( frame, { text: "Hello world" } );
setTimeout(function(){
    sendIFrameData( frame, { text: "How are you today?" } );
}, 2000);





The iframe will listen to the hashchange event and log out what it hears.


var el = document.getElementById('log');
function showMsg(){
    var data = getHashData();
    if ( data && data.text ){
        el.innerHTML += "<br/>Received msg: " + data.text;
    }
}

// in case we sent data on first load.
showMsg();
// when the hash changes we check the new data and print it out
window.addEventListener('hashchange', function(){
    showMsg();
});

Load denied by X-Frame-Obtions in Rails


When i simply adding a iframe by java script  console then it's throw exception message  Load denied by X-Frame-Options: http://localhost:3000/home does not permit cross-origin framing 

Then after searching i found to solution by removing header "X-Frame-Obtions" on response in my Rails application i simply add a method.



after_filter :allow_iframe

private def allow_iframe

  response.headers.delete "X-Frame-Options"

end

And it's working for me...

Friday 10 April 2015

Active Model Dirty

Provides a way to track changes in your object in the same way as Active Record does.

The requirements for implementing ActiveModel::Dirty are:
include ActiveModel::Dirty in your object.
Call define_attribute_methods passing each method you want to track.
Call attr_name_will_change! before each change to the tracked attribute.
Call changes_applied after the changes are persisted. 
Call clear_changes_information when you want to reset the changes information.
Call restore_attributes when you want to restore previous data.

A newly instantiated Person object is unchanged:

person = Person.new
person.changed? # => false
Change the name:
person.name = 'Bob'
person.changed?       # => true
person.name_changed?  # => true
person.name_changed?(from: "Uncle Bob", to: "Bob") # => true
person.name_was       # => "Uncle Bob"
person.name_change    # => ["Uncle Bob", "Bob"]
person.name = 'Bill'
person.name_change    # => ["Uncle Bob", "Bill"]
Save the changes:
person.save
person.changed?      # => false
person.name_changed? # => false
Reset the changes:
person.previous_changes # => {"name" => ["Uncle Bob", "Bill"]}
person.reload!
person.previous_changes # => {}
Rollback the changes:
person.name = "Uncle Bob"
person.rollback!
person.name          # => "Bill"
person.name_changed? # => false
Assigning the same value leaves the attribute unchanged:
person.name = 'Bill'
person.name_changed? # => false
person.name_change   # => nil
Which attributes have changed?

Salesforce CRM vs. Zoho: A Comparative Analysis

Introduction: Selecting the right customer relationship management (CRM) software is crucial for businesses seeking to streamline their sal...